package com.zhangsun.springActiveMq.producer;

import com.zhangsun.springActiveMq.bean.User;
import com.zhangsun.springActiveMq.common.ActiveMqConstant;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;

@Component
public class QueueProducer {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    public void send(String msg) {
        Destination destination = new ActiveMQQueue(ActiveMqConstant.QUEUE_HELLO_1);
        jmsMessagingTemplate.convertAndSend(destination, msg);
    }

    public void send2(User user) {
        Destination destination = new ActiveMQQueue(ActiveMqConstant.QUEUE_HELLO_2);
        jmsMessagingTemplate.convertAndSend(destination, user);
    }

}
